﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using webapi.Domin.Entity;

namespace webapi.Domin
{
    public class Dblnitlizer
    {
        public static void Seed()
        {
            using(Admin977Context db=new Admin977Context())
            {
                db.Database.EnsureCreated();
                var tepUser = db.Users.Any();
                if (!tepUser)
                {
                    var roles = new Roles
                    {
                        RolesName = "有幸",
                        Description = "原来章鱼也有心脏",
                    };
                    db.Roles.Add(roles);
                    db.SaveChanges();

                    db.Users.Add(new Users
                    {
                        UserName = "rmy",
                        Password="654321",
                        RolesId=roles.Id
                    });
                    db.SaveChanges();
                }
            }
        }
    }
}
